<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/easyui.css">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/icon.css">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/demo.css">
<link rel="stylesheet" href="<%=path%>/css/bootstrap.min.css" />
<link rel="stylesheet" href="<%=path%>/css/easyui.css" />
<script type="text/javascript" src="<%=path%>/js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="<%=path%>/js/js_add/jquery-1.8.3.js"></script>
<script type="text/javascript" src="<%=path%>/js/js_add/jquery-ui.js"></script>
<script type="text/javascript" src="<%=path%>/js/js_add/jquery.ui.tabs.js"></script>
<script type="text/javascript" src="<%=path%>/js/jquery.easyui.min.js"></script>

<script type="text/javascript">
	$(function() {
		$("#dg").datagrid({
			url : "<%=path%>/type/getAllPType3?FId=",
			singleSelect: true,//单选效果
			//iconCls: 'icon-search',
			rownumbers : false,
			pagination : true,//显示底部分页栏
			pageSize : 4,//默认每页记录数
			pageList : [ 2, 4, 6 ],
			fitColumns : true,//自适应宽度，防止水平滚动
			striped : true,//隔行变色
			
			toolbar:[{  
            text: '添加',  
            iconCls: 'icon-add',  
            handler: function() {
                //window.location.href='add.jsp';
                $('#dlg').dialog('open').window('center');
            }  
        }, '-', {  
            text: '修改',  
            iconCls: 'icon-edit',  
            handler: function() {  
                //alert("修改");  
                var row=$("#dg").datagrid("getSelected");
                //alert(row.sid);
                //window.location.href='<%=path%>/type/toUp?SId='+row.sid;
                /* setTimeout(function(){
                   alert("页面加载结束后2秒钟时弹出！");
                },5000); */
                //$('#dlg2').dialog('open').window('center'); 
                 $.ajax({
			type: "POST",
			dataType: "json",
			url: "<%=path%>/type/toUp2?SId="+row.sid,
			//data: $('#form1').serialize(),
			success: function (result) {
				if(result=='200'){
				//alert(200);
				//location.href='${pageContext.request.contextPath }/pc/new_back';
				$('#dlg2').dialog('open').window('center'); 
				};			
			},error: function () {
				alert('请检查填写格式,保存失败');
			}			
		});          
            }  
        }, '-',{  
            text: '删除',  
            iconCls: 'icon-remove',  
            handler: function(){  
               var depts=$("#dg").datagrid("getSelected");
               //alert(depts.sid);             
               //删除后返回到当前页
               $.messager.confirm("删除框","确定删除？",function(abc){
	                if(abc){
	                    //alert('正在进行删除..');
	                    $.get("<%=path%>/type/del?SId="+depts.sid,function(aaa){
	                    $("#dg").datagrid("reload");
	              		
	                    });
	                }	                 
	           });         	
            }  
        }],columns : [ [ {field : 'ck',checkbox : true}, 
        {field : 'sid',	title : '项目类型编号',width : 60}, 
        {field : 'sname',title : '项目名称',align : 'center',width : 40},
        {field : 'sdetail',title : '项目介绍',align : 'center',width : 40} ]],
			loadMsg : "正努力为您加载中......"
		});

	});
	function look(fid){
	//alert(fid+'进入look方法了');
	   $('#dlg').dialog('open').window('center');
	}
	
</script>

</head>

<body>
    <div id="dlg2" class="easyui-dialog" title="Toolbar and Buttons"
				style="width:600px;height:400px;padding:20px"
				data-options="closed:true">
				亲,您可以进行修改了
				<form action="<%=path%>/type/up">
					子项目编号:<input name="SId" value="${psType.SId }"/><br>
					 类型:<input name="FId" value="${fid }"/>请加入已有的父类id<br>
					子项目名称:<input name="SName" value="${psType.SName }"/><br>
					子项目介绍:<input name="SDetail" value="${psType.SDetail }"/><br>
					<input type="submit" /> <input type="reset" />
				</form>
			</div>
	<div id="dlg" class="easyui-dialog" title="Toolbar and Buttons"
				style="width:600px;height:400px;padding:20px"
				data-options="closed:true">
				亲,您可以进行添加了
				<form action="<%=path%>/type/add">
					子项目编号:<input name="SId" value=""/><br>
					 类型:<input name="FId" value=""/>请加入已有的父类id<br>
					子项目名称:<input name="SName" value=""/><br>
					子项目介绍:<input name="SDetail" value=""/><br>
					<input type="submit" /> <input type="reset" />
				</form>
			</div>
	<div id="grid" >
		<table id="dg" title="项目类别子项目管理列表">
		</table>
	</div>
	
	
</body>

</html>
